package com.lx;

import java.util.Scanner;

/**
 * @author c先生
 * @date 2022年04月14日 上午 8:37:39
 * @describe
 */

public class main_lx {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Util_lx util = new Util_lx();
        boolean flag = true;
        int id = 1006;
        while (flag) {
            System.out.println("------球员管理系统-------");
            System.out.println("| 1、展示所有球员的信息    |");
            System.out.println("| 2、根据位置展示球员的信息 |");
            System.out.println("| 3、新增一名球员信息      |");
            System.out.println("| 4、修改一名球员信息      |");
            System.out.println("| 5、删除一名球员信息      |");
            System.out.println("-----------------------");
            System.out.println("请输入你的选择");
            switch (sc.nextInt()){
                case 1 :
                    util.showAllPlayer();
                    System.out.println("是否继续？（y/n）");
                    switch (sc.next()){
                        case "y" :
                            flag = true;
                            break;
                        case "n" :
                            flag = false;
                            break;
                    }
                    break;
                case 2 :
                    System.out.println("请输入球员位置：");
                    util.showPlayerInfoByJob(sc.next());
                    System.out.println("是否继续？（y/n）");
                    switch (sc.next()){
                        case "y" :
                            flag = true;
                            break;
                        case "n" :
                            flag = false;
                            break;
                    }
                    break;
                case 3 :
                    System.out.println("请输入球员所属球队：");
                    String qiudui = sc.next();
                    System.out.println("请输入球员名字");
                    String name = sc.next();
                    System.out.println("请输入球员位置");
                    String weizhi = sc.next();
                    System.out.println("请输入球员身高");
                    String height = sc.next();
                    System.out.println("请输入球衣号码");
                    Integer num = sc.nextInt();
                    Player_lx player = new Player_lx(id++,name,weizhi,height,num);
                    boolean flag1 = util.addPlayer(qiudui,player);
                    if(flag1){
                        System.out.println("添加成功！");
                    }else {
                        System.out.println("添加失败！");
                    }
                    System.out.println("是否继续？（y/n）");
                    switch (sc.next()){
                        case "y" :
                            flag = true;
                            break;
                        case "n" :
                            flag = false;
                            break;
                    }
                    break;
                case 4 :
                    System.out.println("请输入修改的球员名称：");
                    Player_lx player2 = util.updatePlayer(sc.next());
                    if(player2 == null){
                        System.out.println("此球员不存在！");
                    }else {
                        System.out.println("原球员名称为："+player2.getPlayerName()+"  请输入修改后的姓名：");
                        player2.setPlayerName(sc.next());
                        System.out.println("原球员位置为："+player2.getPlayerJob()+"  请输入修改后的位置：");
                        player2.setPlayerJob(sc.next());
                        System.out.println("原球员身高为："+player2.getPlayerHeight()+"  请输入修改后的身高：");
                        player2.setPlayerHeight(sc.next());
                        System.out.println("原球员球衣号码为："+player2.getPlayerNum()+"  请输入修改后的球衣号码：");
                        player2.setPlayerNum(sc.nextInt());
                        System.out.println("修改成功！");
                    }
                    System.out.println("是否继续？（y/n）");
                    switch (sc.next()){
                        case "y" :
                            flag = true;
                            break;
                        case "n" :
                            flag = false;
                            break;
                    }
                    break;
                case 5 :
                    System.out.println("请输入要删除的球员姓名：");
                    boolean b = util.deletePlayer(sc.next());
                    if(b){
                        System.out.println("删除成功！");
                    }else {
                        System.out.println("删除失败！");
                    }
                    System.out.println("是否继续？（y/n）");
                    switch (sc.next()){
                        case "y" :
                            flag = true;
                            break;
                        case "n" :
                            flag = false;
                            break;
                    }
                    break;

            }
        }
    }
}
